function C = selectCollections(Q, collection_id, project_id)

%Takes the above varialbles and creates a S3QL insert statement for a
%collection. Q is a struct as described in s3db_read with url and key
%OPTIONAL: project_id

%ROmesh Stanislaus May 2009

if isnumeric(collection_id)
    collection_id = num2str(collection_id);
end
switch nargin
    case 2
        %display(Q); display(collection_id)
        S1 = ['<S3QL><select>*</select><from>collections</from><where><collection_id>',...
            collection_id,'</collection_id></where></S3QL>'];
    case 3
        %display(Q);display(collection_id);display(notes)
        if isnumeric(project_id)
            project_id = num2str(project_id);
        end
        S1 = ['<S3QL><select>*</select><from>collections</from><where><collection_id>',...
            collection_id,'</collection_id><project_id>',...
            project_id,'</project_id></where></S3QL>'];
    otherwise
        error('ddddd')
end

Q.X = S1;

[D1,Q]=s3db_read(Q); % -2

C = D1;